/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package kontroler;

import java.sql.ResultSet;
import java.sql.Statement;

/**
 *
 * @author Renaldo Malau
 */
public class kontrolerLogin{

    public boolean otentikasi (String pemakai, String password){
        //method ini digunakan untuk mengecek apakah username dan password sesuai database
            if (pemakai==null || password==null)
                return (false);

            if (pemakai.equals("")|| password.equals(""))
                return(false);

            boolean passwordCocok=false;
            try{

            databaseConnection.DatabaseConnection conn = new databaseConnection.DatabaseConnection();
            Statement stm = conn.connection.createStatement();

            ResultSet hasil;
            hasil=stm.executeQuery("select password from datalogin where userName='"+pemakai +"'");

            while(hasil.next()){
            if(password.equals(hasil.getString("password")))
                passwordCocok=true;
            }
            return (passwordCocok);
            } catch(Exception e){
                return (passwordCocok);
            }

        }

    

}
